package com.cz.modules.gc.controller;

import java.util.Arrays;
import java.util.Map;

import com.cz.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cz.modules.gc.entity.StatoiletstatusEntity;
import com.cz.modules.gc.service.StatoiletstatusService;
import com.cz.common.utils.PageUtils;
import com.cz.common.utils.R;



/**
 * ${comments}
 *
 * @author Cz
 * @email 
 * @date 2020-06-28 13:56:18
 */
@RestController
@RequestMapping("gc/statoiletstatus")
public class StatoiletstatusController {
    @Autowired
    private StatoiletstatusService statoiletstatusService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("gc:statoiletstatus:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = statoiletstatusService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("gc:statoiletstatus:info")
    public R info(@PathVariable("id") Integer id){
        StatoiletstatusEntity statoiletstatus = statoiletstatusService.getById(id);

        return R.ok().put("statoiletstatus", statoiletstatus);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("gc:statoiletstatus:save")
    public R save(@RequestBody StatoiletstatusEntity statoiletstatus){
        statoiletstatusService.save(statoiletstatus);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("gc:statoiletstatus:update")
    public R update(@RequestBody StatoiletstatusEntity statoiletstatus){
        ValidatorUtils.validateEntity(statoiletstatus);
        statoiletstatusService.updateById(statoiletstatus);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("gc:statoiletstatus:delete")
    public R delete(@RequestBody Integer[] ids){
        statoiletstatusService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     *
     * 获取厕所信息
     */
    @RequestMapping("/getToiletStatus")
    public R getToiletStatus(){
        Map<String,Object> map=statoiletstatusService.getToiletStatus();
        return R.ok().put("data",map);
    }

}
